//
//  ScanPaySuccessVC.m
//  LazyCat
//
//  Created by rocky on 16/4/21.
//  Copyright (c) 2016年 zhanshu. All rights reserved.
//

#import "ScanPaySuccessVC.h"
#import "myWebViewController.h"
@interface ScanPaySuccessVC ()
@property(nonatomic,strong)UITableView *tableView;

@end

@implementation ScanPaySuccessVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
    
}
- (void)backActio{
    NSArray * viewC = self.navigationController.viewControllers;
    [self.navigationController popToViewController:[viewC objectAtIndex:1] animated:YES];
    //[self.navigationController popViewControllerAnimated:YES];
}
-(void)initNav:(NSString*)title doBack:(BOOL)doBack {
    self.navBar.hidden=NO;
    //_resultText = [NSMutableString stringWithString:@"0"];
    self.titleLable.text=title;
    self.titleLable.textColor = [UIColor whiteColor];
    if (doBack) {
        self.backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        self.backBtn.frame=CGRectMake(8, 20+(44-21)/2, 12, 21);
        [self.backBtn setNormalImageWith:@"lALOCzPrgiYW_22_38"];
        [self.backBtn addTarget:self action:@selector(backActio) forControlEvents:UIControlEventTouchUpInside];
        [self.backBtn setHitTestEdgeInsets:UIEdgeInsetsMake(-10, -14, -14, -25)];
        [self.navBar addSubview:self.backBtn];
    }
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
-(void)setupUI
{
    [self initNav:@"扫码付款" doBack:YES];
    self.view.backgroundColor = BackColor;
    self.navBar.backgroundColor = SetColor(0, 140, 206, 1);
    
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, 145)];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];

    UILabel *successLB = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, 200, 18)];
    successLB.textColor = SetColorRGBValue(0x333333, 1.0);
    successLB.text = @"支付成功";
    successLB.font = [UIFont systemFontOfSize:15];
    [topView addSubview:successLB];
    
    UILabel *moneyLB = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(successLB.frame)+20, ScreenWidth, 36)];
    moneyLB.textAlignment = NSTextAlignmentCenter;
    moneyLB.textColor = SetColorRGBValue(0x000000, 1.0);
    moneyLB.text = [NSString stringWithFormat:@"¥%@",_payMoney];
    moneyLB.font = [UIFont systemFontOfSize:30];
    [topView addSubview:moneyLB];
    
    UILabel *timeLB = [[UILabel alloc]initWithFrame:CGRectMake(10, topView.frame.size.height-31, ScreenWidth-100, 16)];
    timeLB.textColor = SetColorRGBValue(0x999999, 1.0);
    timeLB.text = _payTime;
    timeLB.font = [UIFont systemFontOfSize:13];
    [topView addSubview:timeLB];
    
    UILabel *stateLB = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-90, topView.frame.size.height-31, 80, 16)];
    stateLB.textAlignment = NSTextAlignmentRight;
    stateLB.textColor = SetColorRGBValue(0x999999, 1.0);
    stateLB.text = @"收款成功";
    stateLB.font = [UIFont systemFontOfSize:13];
    [topView addSubview:stateLB];
    
    //第一根线
    UIView *firstLine = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(topView.frame), ScreenWidth, 1)];
    firstLine.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [self.view addSubview:firstLine];
    
    
    CGFloat aY = CGRectGetMaxY(topView.frame)+15;
    UIView *midLine = [[UIView alloc]initWithFrame:CGRectMake(0, aY, ScreenWidth, 1)];
    midLine.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [self.view addSubview:midLine];
    
    //中间
    UIView *midView = [[UIView alloc]init];
    midView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:midView];
    
    UILabel *lc_left1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 32, 44)];
    lc_left1.text = @"备注";
    lc_left1.font = [UIFont systemFontOfSize:15];
    lc_left1.textColor = SetColorRGBValue(0x333333, 1.0);
    [midView addSubview:lc_left1];
    
    UILabel *lc_right1 = [[UILabel alloc]init];
    lc_right1.text = _notesStr;
    CGSize lc_rightSize = [lc_right1.text boundingRectWithSize:CGSizeMake(ScreenWidth-60, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
    lc_right1.frame = CGRectMake(50, 14.5, ScreenWidth-60, lc_rightSize.height);
    midView.frame = CGRectMake(0, aY+1, ScreenWidth, lc_rightSize.height+29);
    lc_right1.numberOfLines = 0;
    lc_right1.lineBreakMode = NSLineBreakByCharWrapping;
    lc_right1.font = [UIFont systemFontOfSize:13];
    lc_right1.textColor = SetColorRGBValue(0x999999, 1.0);
    [midView addSubview:lc_right1];
    
    
    //底部
    CGFloat aY1 = CGRectGetMaxY(midView.frame);
    UIView *bottomLine = [[UIView alloc]initWithFrame:CGRectMake(10, aY1, ScreenWidth, 1)];
    bottomLine.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [self.view addSubview:bottomLine];
    
    UIView *bottomeView = [[UIView alloc]initWithFrame:CGRectMake(0, aY1+1, ScreenWidth, 44)];
    bottomeView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bottomeView];
    
    UILabel *lc_left2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 50, 44)];
    lc_left2.text = @"订单号";
    lc_left2.font = [UIFont systemFontOfSize:15];
    lc_left2.textColor = SetColorRGBValue(0x333333, 1.0);
    [bottomeView addSubview:lc_left2];
    
    UILabel *lc_right2 = [[UILabel alloc]initWithFrame:CGRectMake(68, 14, ScreenWidth-78, 16)];
    lc_right2.text = _orderNum;
    lc_right2.font = [UIFont systemFontOfSize:13];
    lc_right2.textColor = SetColorRGBValue(0x999999, 1.0);
    [bottomeView addSubview:lc_right2];
    
    UIView *lastLine = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(bottomeView.frame), ScreenWidth, 1)];
    lastLine.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [self.view addSubview:lastLine];
    
    //“打印小票”按钮
    UIButton *printTicket = [UIButton buttonWithType:UIButtonTypeCustom];
    printTicket.frame = CGRectMake(10, CGRectGetMaxY(lastLine.frame)+25, ScreenWidth-20, 44);
    printTicket.layer.masksToBounds = YES;
    printTicket.layer.cornerRadius = 10;
    [printTicket setTitleColor:SetColorRGBValue(0xffffff, 1.0) forState:UIControlStateNormal];
    [printTicket setTitle:@"查看订单" forState:UIControlStateNormal];
    printTicket.backgroundColor = SetColor(0, 140, 206, 1);
    [self.view addSubview:printTicket];
    
    [printTicket addTarget:self action:@selector(printTicketClicked) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}
-(void)printTicketClicked{//跳转到查看订单
    myWebViewController *webVC = [[myWebViewController alloc]init];
    //#define scanForPayOrderListUrl BaseUrl @"/profile/F2FPayOrder?username=%@&sign2=%@&plat=ios&terminal=%@&OSVersion=%@"
    NSUserDefaults *userDefaul = [NSUserDefaults standardUserDefaults];
    NSString *iptype = [userDefaul objectForKey:@"iptype"];
    NSString *banben = [userDefaul objectForKey:@"banben"];
    webVC.requestUrl = [NSString stringWithFormat:scanForPayOrderListUrl,[AppData share].username,[Utils md5SignStr],iptype,banben];
    NSLog(@"%@",webVC.requestUrl);
    webVC.titleName = @"查看订单";
    [self.navigationController pushViewController:webVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
